package link.gpt.dao;

import java.util.List;
import link.gpt.pojo.GoodsDetail;
import link.gpt.pojo.GoodsDetailExample;
import org.apache.ibatis.annotations.Param;

public interface GoodsDetailDao {
    long countByExample(GoodsDetailExample example);

    int deleteByExample(GoodsDetailExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(GoodsDetail record);

    int insertSelective(GoodsDetail record);

    List<GoodsDetail> selectByExample(GoodsDetailExample example);

    GoodsDetail selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") GoodsDetail record, @Param("example") GoodsDetailExample example);

    int updateByExample(@Param("record") GoodsDetail record, @Param("example") GoodsDetailExample example);

    int updateByPrimaryKeySelective(GoodsDetail record);

    int updateByPrimaryKey(GoodsDetail record);

    /**
     *  根据id查询商品详情
     * @param id
     * @return
     */
   GoodsDetail findById(Integer id);

    /**
     * 购买商品,根据剩余数量
     * @param id
     * @param num
     * @return
     */
    int buyGoods(@Param("id") Integer id, @Param("num") int num);

    /**
     * 根据分类查询,分页
     * @param sortId
     * @return
     */
    List<GoodsDetail> findAllBySortIdAndPage(Integer sortId);
}